10 REM SURFACE WAVES ON A GROUNDED DIELECTRIC SLAB
20 REM "ANTENNA DESIGN USING PERSONAL COMPUTERS"
30 KEY OFF
40 PI=3.141593
50 CLS
60 COLOR 1,0
70 PRINT "THIS PROGRAM COMPUTES THE SURFACE WAVE PROPAGATION CONSTANTS"
80 PRINT "OF A GROUNDED DIELECTRIC SLAB."
90 COLOR 4,0
100 PRINT
110 INPUT "WHAT IS THE FREQUENCY(MHz)";FMC
120 INPUT "WHAT IS THE THICKNESS OF THE SUBSTRATE(meters)";D
130 INPUT "WHAT IS THE RELATIVE DIELECTRIC CONSTANT";EPS
140 PRINT
150 COLOR 14,0
160 XK0=2*PI*FMC/300
170 NSW%=INT(1+2*XK0*D*SQR(EPS-1)/PI)
180 PRINT USING "THERE ARE ## SURFACE WAVE MODES";NSW%
190 DELTA=.00001*XK0
200 BT2=XK0-DELTA
210 FOR I%=1 TO NSW%
220 REM IEM%=1 FOR TM MODES; =3 FOR TE MODES
230 IEM%=2-(-1)^(I%+NSW%)
240 BT1=BT2+2*DELTA
250 BT2=SQR(EPS*XK0*XK0-((NSW%-I%)*PI*.5/D)^2)
260 GOSUB 370
270 TEM$="TM"
280 IF IEM%=3 THEN TEM$="TE"
290 BTN=BTN/XK0
300 PRINT USING "& SURFACE WAVE PROPAGATION CONSTANT/ko=##.#####";TEM$,BTN
310 NEXT I%
320 PRINT
330 COLOR 4,0
340 INPUT "CONTINUE(Y,N)";IS$
350 IF IS$<>"N" THEN GOTO 50
360 GOTO 740
370 REM ROOT SEARCH USING NEWTON RHAPSON ITERATION
380 REM FIRST USE INTERVAL HALVING TO GET CLOSE TO ROOT
390 DB=(BT2-BT1)/30
400 XK0S=XK0*XK0
410 FOR J=1 TO 30
420 BT=BT1+(J-1)*DB
430 BTS=BT*BT
440 XK1=SQR(EPS*XK0S-BTS)
450 XK2=-SQR(BTS-XK0S)
460 IF IEM%=1 THEN G=EPS*XK2/XK1
470 IF IEM%=3 THEN G=-XK1/XK2
480 F=SIN(XK1*D)/COS(XK1*D)+G
490 IF J=1 THEN 510
500 IF F*F1<0 THEN GOTO 530
510 F1=F
520 NEXT J
530 BT=BT-DB
540 ITER=0
550 BTS=BT*BT
560 XK1=SQR(EPS*XK0S-BTS)
570 XK2=-SQR(ABS(BTS-XK0S))
580 IF IEM%=1 THEN G=EPS*XK2/XK1
590 IF IEM%=3 THEN G=-XK1/XK2
600 F=SIN(XK1*D)/COS(XK1*D)+G
610 IF IEM%=1 THEN GP=EPS*BT*(1/XK2+XK2/XK1^2)/XK1
620 IF IEM%=3 THEN GP=BT*(1/XK1+XK1/XK2^2)/XK2
630 FP=-BT*D/(XK1*COS(XK1*D)^2)+GP
640 BTN=BT-F/FP
650 BTNS=BTN
660 ER=ABS((BTN-BT)/BT)
670 IF ER<.00001 THEN GOTO 730
680 ITER=ITER+1
690 IF ITER>20 THEN PRINT "ITERATIONS EXCEEDED"
700 BT=BTN
710 IF BT<BT1 OR BT>BT2 THEN PRINT "ERROR IN NEWRHAP"
720 GOTO 550
730 RETURN
740 COLOR 7,0
750 KEY ON
760 END
